phrase = input()
brackets_o = "([{<"
brackets_c = ")]}>"
mystack = []
brackets_match = True
for char in phrase:
    if char in brackets_o:
        mystack.append(char)
    if char in brackets_c:
        if len(mystack) == 0 or brackets_c.find(char) != brackets_o.find(mystack.pop()):
            brackets_match = False
            break
        
print(len(mystack) == 0 and brackets_match)
